package com.mblog.article.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mblog.util.PageBean;
import com.mblog.util.PageHelper;
import com.mblog.article.dao.MBlogMainMapper;
import com.mblog.article.entity.MBlogMain;
import com.mblog.util.PageHelper;
import com.mblog.util.PageHelper.Page;
import com.mblog.util.PageHelper.PageCall;

@Service("ArticleService")
public class ArticleServiceImp implements ArticleService{

	@Autowired
	MBlogMainMapper mBlogMainMapper;
	@Override
	public int deleteByPrimaryKey(Integer id) {

		return mBlogMainMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MBlogMain record) {
		
		return mBlogMainMapper.insert(record);
	}

	@Override
	public MBlogMain selectByPrimaryKey(Integer id) {
		
		return mBlogMainMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<MBlogMain> selectAll(Map<String, Object> map) {
		
		return mBlogMainMapper.selectAll(map);
	}

	@Override
	public int updateByPrimaryKey(MBlogMain record) {
		
		return mBlogMainMapper.updateByPrimaryKey(record);
	}


	public PageBean selectAllArticleByPage(int pageNo, int pageSize, final Map<String, Object> map) {
		return PageHelper.pagedQuery(new PageCall() {
			@Override
			public void executeQuery() {
				mBlogMainMapper.selectAll(map);
			}
		}, pageNo, pageSize);
	}

	@Override
	public List<MBlogMain> selectAllArticleTags() {
		
		return mBlogMainMapper.selectAllArticleTags();
	}

	@Override
	public MBlogMain selectPreArticleById(Integer id) {
		
		return mBlogMainMapper.selectPreArticleById(id);
	}

	@Override
	public MBlogMain selectNextArticleById(Integer id) {
		
		return mBlogMainMapper.selectNextArticleById(id);
	}
	
}